import { NoticeService } from './../../../providers/notice-service';
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { Api } from '../../../providers/api-service';
import { UrlService } from '../../../providers/url-service';
import { UserInfo } from '../../../global/ConstUrl';

/**
 * 心路历程
 */
@Component({
  selector: 'page-user-lichan',
  templateUrl: 'user-lichan.html',
})
export class UserLichanPage {

  public user;
  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public api: Api,
    public urlService: UrlService,
    public noticeService: NoticeService
  ) {
    this.user = {
      headimg: "",
      DekaronWin: "",
      PublicDe: "",
      DekaronLose: "",
      JoinDe: "",
      RejestDate: "",
      PublicDekaronDate: "",
      DekaronDate: "",
      PublicConversationDate: "",
      shareDate: ""
    };
   
  }

  ionViewDidLoad() {
    //console.log('ionViewDidLoad UserLichanPage');
     this.init();
  }

  init() {
    this.urlService.GetMyNewInfo()
      .then(data => {
        try {
          let obj = data.Data;
        
          this.user = {
            headimg: UserInfo().ImgUrl,
            DekaronWin: obj.DekaronWin == undefined ? 0 : obj.DekaronWin,
            PublicDe: obj.PublicDe == undefined ? 0 : obj.PublicDe,
            DekaronLose: obj.DekaronLose,
            JoinDe: obj.JoinDe == undefined ? 0 : obj.JoinDe,
            RejestDate: obj.RejestDate,
            PublicDekaronDate: obj.PublicDekaronDate,
            DekaronDate: obj.DekaronDate,
            PublicConversationDate: obj.PublicConversationDate,
            shareDate: obj.shareDate
          }
        } catch (error) {
          this.noticeService.showNoticeByToast(1, error.Msg);
        } finally {
          //console.log(this.user);
        }
      })
      .catch(error => {
        this.noticeService.showNoticeByToast(1, error.Msg);
      });
  }
}
